package swagger

import (
	"fmt"
	"gitee.com/injoyai/goutil/conv"
	"net/http"
)

func Handler(jsonPath ...string) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte(UI(jsonPath...)))
		w.WriteHeader(200)
	})
}

func UI(jsonPath ...string) string {
	path := conv.GetDefaultString("/swagger/swagger.json", jsonPath...)
	return fmt.Sprintf(ui, path)
}
